<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link href="{{ asset("/components/AdminLTE/bootstrap/css/bootstrap.min.css") }}" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="{{asset("/components/AdminLTE/dist/css/AdminLTE.min.css")}}">
    <script src="/dist/js/jquery-1.11.3.min.js"></script>
</head>
<body>
<section class="content">
    <div class="row">
        <!-- left column -->
        <div class="col-md-6">
            <!-- general form elements -->
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title">API测试客户端</h3>
                </div>
                <!-- /.box-header -->
                <!-- form start -->
                    <div class="box-body">
                        <div class="form-group">
                            <label for="exampleInputEmail1">API地址</label>
                            <input id="url" type="url" class="form-control"  placeholder="http://139.129.194.77/api/session">
                        </div>
                        <div class="form-group">
                            <label for="exampleInputPassword1">session-id</label>
                            <input name="session_id" type="text" class="form-control" id="session_id" placeholder="asdfasdfasldfasdfasfdasfd">
                        </div>
                        <div class="form-group">
                            <textarea id="body" rows="10" style="width: 100%" placeholder='{"a":"b"}'></textarea>
                        </div>

                    </div>
                    <!-- /.box-body -->

                    <div class="box-footer">
                        <button id="button" type="button" class="btn btn-primary">提交</button>
                    </div>

            </div>
            <!-- /.box -->



        </div>
        <div class="col-md-6">
            <!-- general form elements -->
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title">返回结果</h3>
                </div>
                <!-- /.box-header -->
                <!-- form start -->
                    <!-- /.box-body -->

                    <div class="box-body">

                        <div class="form-group">
                            <label for="exampleInputPassword1">HTTP请求状态:<font style="color: red;" id="status"></font></label>
                            <textarea id="result" rows="10" style="width: 100%" placeholder='{"a":"b"}'></textarea>
                        </div>

                    </div>
            </div>
            <!-- /.box -->



        </div>

    </div>
    <!-- /.row -->
</section>


<script type="text/javascript">
$("#button").click(function(e){

    var data = {
        'url':$('#url').val(),
        'session_id':$('#session_id').val(),
        'body':$('#body').val()
    }

    console.log(data);
    $.ajax({
        url:'/api_client/request_ok',
        type:'post',
        dataType:'json',
        data:data,
        success:function(res){
            console.log(res.status);


            if (res.status=="0") {
                status = '请求失败'
            }else{
                status = res.status;
            }
            console.log(status);
            $('#status').html(status);
            $('#result').val(res.body);


        }
    });


});

</script>


</body>
</html>